package com.lcf.system.controller;


import cn.dev33.satoken.annotation.SaCheckPermission;
import com.lcf.framework.vo.PageVO;
import com.lcf.system.dto.GoodsCommentDTO;
import com.lcf.system.query.GoodsCommentPageQuery;
import com.lcf.system.service.GoodsCommentService;
import com.lcf.system.vo.GoodsCommentVO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * 商品评价(GoodsComment)表控制层
 *
 * @author lcf
 * @since 2025-05-02 11:55:00
 */
@Tag(name = "商品评价")
@RestController
@RequestMapping("goodsComment")
public class GoodsCommentController {
    @Resource
    private GoodsCommentService goodsCommentService;

    /**
     * 新增
     */
    @Operation(summary = "新增商品评价")
    @SaCheckPermission("goodsComment:add")
    @PostMapping("add")
    public boolean addGoodsComment(@RequestBody @Validated GoodsCommentDTO dto) {
        return goodsCommentService.addGoodsComment(dto);
    }

    /**
     * 删除
     */
    @Operation(summary = "删除商品评价")
    @SaCheckPermission("goodsComment:delete")
    @DeleteMapping("{id}")
    public boolean deleteGoodsComment(@PathVariable @Schema(description = "商品评论ID") long id) {
        return goodsCommentService.deleteGoodsComment(id);
    }

    /**
     * 修改
     */
    @Operation(summary = "修改商品评价")
    @SaCheckPermission("goodsComment:update")
    @PatchMapping("{id}")
    public boolean updateGoodsComment(@PathVariable @Schema(description = "商品评论ID") long id,
                                      @RequestBody @Validated GoodsCommentDTO dto) {
        return goodsCommentService.updateGoodsComment(id, dto);
    }

    /**
     * 根据id查询
     */
    @Operation(summary = "查询商品评价")
    @SaCheckPermission("goodsComment:query")
    @GetMapping("{id}")
    public GoodsCommentVO getGoodsComment(@PathVariable @Schema(description = "商品评论ID") long id) {
        return goodsCommentService.getGoodsComment(id);
    }

    /**
     * 分页查询
     */
    @Operation(summary = "分页查询商品评价")
    @SaCheckPermission("goodsComment:query")
    @GetMapping("page")
    public PageVO<GoodsCommentVO> getGoodsCommentList(GoodsCommentPageQuery query) {
        return goodsCommentService.getGoodsCommentList(query);
    }
}

